Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close spider by stats [#47][#50] #216

Closed
wants to merge 4 commits into from
Closed

Conversation

rosheen33
Copy link

@rosheen33 rosheen33 commented Sep 23, 2019

Just an initial version of the solution.

I have added a new setting in spidermon as proposed by @raphapassini above

SPIDERMON_CLOSESPIDER_BY_STATS = {
    "spidermon/validation/": 10,
}

Note: Documentation is not added so far

I have implemented the solution
Please have a look

#47
#50

)
pipeline._set_crawler(crawler)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not pass it as a parameter to cls()?

if stat_current_value > max_errors_allowed:
self.crawler.engine.close_spider(
spider,
'Spidermon: No of errors are greater then the expected no of errors {} > {}'.format(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not call them errors (they could be warnings or something else entirely), and I would include the name of the specific stat that triggers the spider closing.

Suggested change
'Spidermon: No of errors are greater then the expected no of errors {} > {}'.format(
'Spidermon: The value of stat {} ({}) went above the configured limit ({})'.format(stat_name, stat_current_value, max_errors_allowed)

Copy link
Collaborator

@rennerocha rennerocha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rosheen33 did you saw my comment on #47 ?

@rennerocha rennerocha closed this Jul 31, 2022
@rennerocha rennerocha deleted the close_spider_by_stats branch July 31, 2022 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants